package com.ghy.service.impl;

import com.ghy.entity.EbNews;
import com.ghy.mapper.NewsMapper;
import com.ghy.service.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class NewsServiceImpl implements NewsService {
    @Autowired
    private NewsMapper newsMapper;

    @Override
    public List<EbNews> listByPage(int page, int pageSize) {
        int from = (page-1)*pageSize;
        return newsMapper.findByPage(from,pageSize);
    }

    @Override
    public Integer getMaxPage(Integer pageSize){
        return newsMapper.getMaxPage(pageSize);
    }

    @Override
    public Integer save(EbNews ebNews){
        return newsMapper.save(ebNews);
    }

    @Override
    public EbNews selectOne(Integer enId){
        return newsMapper.selectOne(enId);
    }

    @Override
    public int updateById(EbNews ebNews){
        return  newsMapper.updateByPrimaryKey(ebNews);
    }

    @Override
    public int remove(int enId) {
        return newsMapper.remove(enId);
    }

    @Override
    public int updateNews(EbNews ebNews){
        return newsMapper.updateByPrimaryKey(ebNews);
    }

}
